package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ResidentialBuildings;
import com.ruoyi.system.service.IResidentialBuildingsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * residential_buildingsController
 * 
 * @author wfj
 * @date 2025-11-23
 */
@RestController
@RequestMapping("/system/residentialBuildings")
public class ResidentialBuildingsController extends BaseController
{
    @Autowired
    private IResidentialBuildingsService residentialBuildingsService;

    /**
     * 查询residential_buildings列表
     */
    @PreAuthorize("@ss.hasPermi('system:residentialBuildings:list')")
    @GetMapping("/list")
    public TableDataInfo list(ResidentialBuildings residentialBuildings)
    {
        startPage();
        List<ResidentialBuildings> list = residentialBuildingsService.selectResidentialBuildingsList(residentialBuildings);
        return getDataTable(list);
    }

    /**
     * 导出residential_buildings列表
     */
    @PreAuthorize("@ss.hasPermi('system:residentialBuildings:export')")
    @Log(title = "residential_buildings", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ResidentialBuildings residentialBuildings)
    {
        List<ResidentialBuildings> list = residentialBuildingsService.selectResidentialBuildingsList(residentialBuildings);
        ExcelUtil<ResidentialBuildings> util = new ExcelUtil<ResidentialBuildings>(ResidentialBuildings.class);
        util.exportExcel(response, list, "residential_buildings数据");
    }

    /**
     * 获取residential_buildings详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:residentialBuildings:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(residentialBuildingsService.selectResidentialBuildingsById(id));
    }

    /**
     * 新增residential_buildings
     */
    @PreAuthorize("@ss.hasPermi('system:residentialBuildings:add')")
    @Log(title = "residential_buildings", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ResidentialBuildings residentialBuildings)
    {

        return toAjax(residentialBuildingsService.insertResidentialBuildings(residentialBuildings));
    }

    /**
     * 修改residential_buildings
     */
    @PreAuthorize("@ss.hasPermi('system:residentialBuildings:edit')")
    @Log(title = "residential_buildings", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ResidentialBuildings residentialBuildings)
    {
        return toAjax(residentialBuildingsService.updateResidentialBuildings(residentialBuildings));
    }

    /**
     * 删除residential_buildings
     */
    @PreAuthorize("@ss.hasPermi('system:residentialBuildings:remove')")
    @Log(title = "residential_buildings", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(residentialBuildingsService.deleteResidentialBuildingsByIds(ids));
    }
}
